package com.otupia.acs.spring.Impl;

import org.apache.log4j.Logger;

import com.otupia.acs.entity.UserInfo;
import com.otupia.acs.spring.api.UserManager;
import com.otupia.acs.spring.dao.UserDao;

public class UserManagerBeanSpring implements UserManager
{
	private static Logger logger = Logger.getLogger(UserManagerBeanSpring.class);
	private UserDao userDao;
	
	public void setUserDao(UserDao userDao)
	{
		this.userDao = userDao;
	}

	public void register(final UserInfo userInfo)
	{
		logger.info("calling function UserManagerBeanSpring"
				+ "#register with arguments : [" + userInfo + "]");
		
		userDao.createUser(userInfo);
		
		logger.info("exiting function UserManagerBeanSpring"
				+ "#register with result : [" + userInfo + "]");
	}

	public void removeUser(long userId)
	{
		logger.info("calling function UserManagerBeanSpring"
				+ "#removeUser with arguments : [" + userId + "]");
		
		UserInfo tempUserInfo = new UserInfo();
		tempUserInfo.setId(userId);
		userDao.deleteUser(tempUserInfo);
		
		logger.info("exiting function UserManagerBeanSpring"
				+ "#removeUser with result : [" + userId + "]");
	}

	public UserInfo findUser(long userId)
	{
		logger.info("calling function UserManagerBeanSpring"
				+ "#findUser with arguments : [" + userId + "]");
		
		this.userDao.findeUserById(userId);
		
		logger.info("exiting function UserManagerBeanSpring"
				+ "#findUser with result : [" + userId + "]");
		return null;
	}

	public void updateUser(UserInfo userInfo)
	{
		logger.info("calling function UserManagerBeanSpring"
				+ "#updateUser with arguments : [" + userInfo + "]");
		
		this.userDao.updateUser(userInfo);
		
		logger.info("exiting function UserManagerBeanSpring"
				+ "#updateUser with result : [" + userInfo + "]");
	}

}
